<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<h1>Your orders:</h1>
<table border="1" cellpadding="10" cellspacing="0">
		<tr>
			<th>book</th>
			<th>count</th>
			<th>address</th>
			<th>payment</th>
			<th>status</th>
			<th>date</th>
			<th>cancel</th>
			<th>return</th>
		</tr>
		
	<c:forEach items="${sessionScope.user.orders}" var="order">
		
		<tr>
		
	    <td><a href="<c:url value="/book/${order.book.id}" />">${order.book.name}</a></td>
	    <td>${order.count}</td> 
	    <td>${order.address}</td>
	    <td>${order.payment}</td>
	    <td><c:if test="${order.status == 1}">New order</c:if> <c:if test="${order.status == 0}">Bought</c:if>
	    <c:if test="${order.status == -1}">Pre-order</c:if> <c:if test="${order.status < -1}">In process</c:if></td>
	    <td>${order.date}</td>
	    <td><c:if test="${order.status == 1 || order.status == -1}"><a href="<c:url value="orders/cancel/${order.id}"/>">Cancel this Order</a></c:if></td>
	    <td><c:if test="${order.status == 0}"><a href="<c:url value="return/${order.id}"/>">Return this books</a></c:if></td>
    	</tr>
    	
	</c:forEach>
	</table>
</body>
</html>